<template>
    <div>
        <el-form :model="ruleForm" ref="ruleForm"  :rules = "rules" :label-position="labelPosition" label-width="120px" class="demo-ruleForm">
            <div class="container" style="margin-top:20px;">
                <el-row>
					<el-col :span="12">
						<el-form-item label="货物名称：" prop="goodsName">
						    <el-input placeholder="请输入内容" v-model="ruleForm.goodsName" style="width: 300px"></el-input>
						</el-form-item>
						<el-form-item label="货物估值：" prop="goodsValue">
						    <el-input placeholder="请输入内容" v-model="ruleForm.goodsValue" style="width: 300px"></el-input>
						</el-form-item>
						<el-form-item label="保质期：" prop="expiration">
						    <el-input placeholder="请输入内容" v-model="ruleForm.expiration" style="width: 300px"></el-input>  天
						</el-form-item>
						<el-form-item label="货物品级：" prop="goodsLevel">
							<el-select v-model="ruleForm.goodsLevel"  value-key="id" filterable placeholder="请选择" style="width: 300px;">
								<el-option
									v-for="item in unit"
									:key="item.id"
									:label="item.name"
									:value="item.id"
								>
								{{item.name}}
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="货主名称：" prop="">
						    <el-input placeholder="请输入内容" v-model="ruleForm.ownerName" style="width: 300px"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="10">
						<el-form-item label="入库数量：" prop="goodsNum">
						    <el-input placeholder="请输入内容" v-model="ruleForm.goodsNum" style="width: 300px"></el-input>  kg
						</el-form-item>
						<el-form-item label="入库批次：" prop="batch">
						    <el-input placeholder="请输入内容" v-model="ruleForm.batch" style="width: 300px"></el-input>
						</el-form-item>
						<el-form-item label="种植批次：" prop="plantBatch">
						    <el-input placeholder="请输入内容" v-model="ruleForm.plantBatch" style="width: 300px"></el-input>
						</el-form-item>

						<el-form-item label="存货类型：" prop="type">
							<el-select v-model="ruleForm.type"  value-key="id" filterable placeholder="请选择" style="width: 300px;">
								<el-option
									v-for="item in type"
									:key="item.id"
									:label="item.name"
									:value="item.name"
								>
								{{item.name}}
								</el-option>
							</el-select>
						</el-form-item>
					</el-col>
				</el-row>
            </div>


            <el-form-item class="footerFixed" label-width="0px">
                <el-button type="primary" @click="submitrule('ruleForm')">入库</el-button>
                <el-button @click="backPage">返回</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
	import axios from "axios"
	import uploadImg from '../../../common/uploadImg';
    import {client_save,client_findById,client_update} from '@/request/api'
    import {regionData,CodeToText} from 'element-china-area-data'
    export default {
		components: {
		    uploadImg
		},
        data() {
            return {

				listUrl1:'',
				settleTypelist:[],
                options: regionData,
                selectedOptions: [],
                labelPosition:'right',
                allMessage: '',

                ruleForm: {

                },
                rules:{

                },
				id:'',
				unit:[],
				type:[{
					name:"存放",
					id:1
				},{
					name:'抵押',
					id:2
				}
				]
            }
        },
        mounted(){
			this.id = this.$route.query.id
			this.ruleForm.shelvesId = this.id
           // if(this.id == undefined){

           // }else{
               this.init()
           // }
        },
        methods: {
			// 根据id 获取详细信息
            init(){
				axios.get("http://grove.cpzsyun.com:81/api/control/goodsLevel/findList").then((res)=>{
					this.unit = res.data.data
				})
            },
			// 添加货架

		   // 返回上一页
            backPage () {
                this.$router.go(-1);
            },
			// 提交
            submitrule(formName) {

				if(this.ruleForm.type == "存放"){
					this.ruleForm.type = 1
				}else{
					this.ruleForm.type = 2
				}
				// this.ruleForm.positionList = this.positionList
				let data = this.ruleForm
                axios.post("http://grove.cpzsyun.com:81/api/control/goods/save",data).then((res)=>{
                	this.$notify({
                	    title: '提示',
                	    message: '入库成功',
                	    type: 'success',
                	    duration: 500
                	});
                	this.backPage()
                })
            },


        }
    }
</script>

<style scoped lang="less">
.demo-ruleForm{
    margin-top: 10px;
}
.demo-ruleForm .el-radio--small.is-bordered{
    width: 120px !important;
    margin-right: 10px !important;
}
.box{
    width: 85%;
    margin-bottom: 15px;
    dl{
        margin-bottom: 20px;
        overflow: hidden;
        dt{ margin-bottom: 5px; font-size: 14px;}
        dd{ font-weight: 500; font-size: 12px; float: left; width: 50%; line-height: 24px;}
    }
    dl:last-child{
        margin-bottom: 0;
    }
    .el-col-11{
        height: 200px;
        overflow-y: auto;
        margin-left: 10px;
        border-left: 1px solid #EBEEF5;
        padding-left: 10px;
        p{ color: #303133;}
        .record-tip-con{
            padding-top: 10px;
        }
    }
}
</style>
